import Content from '@/sheep/layouts/content.vue';
import { request } from '@/sheep/request';
import { SELECT, CRUD } from '@/sheep/request/crud';

const route = {
  path: 'video',
  name: 'shop.admin.video',
  component: Content,
  meta: {
    title: '视频合成',
  },
  children: [
    {
      path: 'synthesis',
      name: 'shop.admin.video.synthesis',
      component: () => import('./synthesis/index.vue'),
      meta: {
        title: '视频合成',
      },
    },
    {
      path: 'category',
      name: 'shop.admin.video.category',
      component: () => import('./category/index.vue'),
      meta: {
        title: '模版分类',
      },
    },
    {
      path: 'list',
      name: 'shop.admin.video.list',
      component: () => import('./list/index.vue'),
      meta: {
        title: '视频列表',
      },
    },
    {
      path: 'log',
      name: 'shop.admin.video.log',
      component: () => import('./log/index.vue'),
      meta: {
        title: '合成记录',
      },
    },
    {
      path: 'template',
      name: 'shop.admin.video.template',
      component: () => import('./template/index.vue'),
      meta: {
        title: '视频模版',
      },
    }
  ],
};

const api = {
  agent: {
    ...CRUD('shop/admin/commission/agent', ['list', 'detail', 'edit', 'delete']),

    select: (params) => SELECT('shop/admin/commission/agent', params),

    changeParentUser: (id, data) =>
      request({
        url: `shop/admin/commission/agent/changeParentUser/${id}`,
        method: 'POST',
        data,
        options: {
          showSuccessMessage: true,
        },
      }),

    team: (id) =>
      request({
        url: `shop/admin/commission/agent/team/${id}`,
        method: 'GET',
      }),
  },
  level: {
    ...CRUD('shop/admin/commission/level'),
    select: (params) => SELECT('shop/admin/commission/level', params),
  },
  order: {
    ...CRUD('shop/admin/commission/order', ['list']),
    confirm: (params) =>
      request({
        url: `shop/admin/commission/order/confirm`,
        method: 'POST',
        params,
        options: {
          showSuccessMessage: true,
        },
      }),
    cancel: (params) =>
      request({
        url: `shop/admin/commission/order/cancel`,
        method: 'POST',
        params,
        options: {
          showSuccessMessage: true,
        },
      }),
    back: (params) =>
      request({
        url: `shop/admin/commission/order/back`,
        method: 'POST',
        params,
        options: {
          showSuccessMessage: true,
        },
      }),
    edit: (params) =>
      request({
        url: `shop/admin/commission/order/edit`,
        method: 'POST',
        params,
        options: {
          showSuccessMessage: true,
        },
      }),
  },
  log: {
    ...CRUD('shop/admin/commission/log', ['list']),
  },
  reward: {
    ...CRUD('shop/admin/commission/reward', ['list']),
  },
  goods: {
    ...CRUD('shop/admin/commission/goods', ['list', 'detail', 'edit']),
  },
};

export { route, api };
